package tech.lq0.dreamaticvoyage.init;

import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.registries.RegistryObject;
import tech.lq0.dreamaticvoyage.block.entity.LightBreadEnergyBlockEntity;
import tech.lq0.dreamaticvoyage.block.entity.MoltenBreadEnergyBlockEntity;
import tech.lq0.dreamaticvoyage.item.fukamizutech.UCEnergyBlockItem;

import java.util.ArrayList;
import java.util.List;

public class ModTabs {

    private static final List<RegistryObject<Item>> HIDDEN = new ArrayList<>();

    static {
        HIDDEN.add(ItemRegistry.SUSPICIOUS_BLUE_SAND);
    }

    public static CreativeModeTab ITEM_TAB = CreativeModeTab.builder()
            .title(Component.translatable("itemGroup.dreamaticvoyage_items_tab"))
            .icon(() -> new ItemStack(ItemRegistry.RED_AHOGE.get()))
            .displayItems((param, output) -> ItemRegistry.ITEMS.getEntries().forEach((registryObject) -> {
                if (!HIDDEN.contains(registryObject)) {
                    output.accept(registryObject.get());
                }
            }))
            .build();

    public static CreativeModeTab MISC_TAB = CreativeModeTab.builder()
            .title(Component.translatable("itemGroup.dreamaticvoyage_misc_tab"))
            .withTabsBefore(TabRegistry.MOD_ITEM_TAB.getKey())
            .icon(() -> new ItemStack(ItemRegistry.CRYSTAL_POWDER.get()))
            .displayItems((param, output) -> ItemRegistry.MISC_ITEMS.getEntries().forEach((registryObject) -> {
                if (!HIDDEN.contains(registryObject)) {
                    output.accept(registryObject.get());
                }
            }))
            .build();

    public static CreativeModeTab BLOCK_TAB = CreativeModeTab.builder()
            .title(Component.translatable("itemGroup.dreamaticvoyage_blocks_tab"))
            .withTabsBefore(TabRegistry.MOD_MISC_TAB.getKey())
            .icon(() -> new ItemStack(ItemRegistry.BLUE_SAND.get()))
            .displayItems((param, output) -> {
                output.accept(ItemRegistry.RED_AHOGE_BLOCK.get());
                output.accept(ItemRegistry.WHITE_AHOGE_BLOCK.get());
                output.accept(ItemRegistry.COMMUNICATION_TABLE.get());
                output.accept(ItemRegistry.PORCELAIN_THRONE.get());
                output.accept(ItemRegistry.POINTS_STORE.get());

                output.accept(ItemRegistry.BLUE_SAND.get());
                output.accept(ItemRegistry.BLUE_SANDSTONE.get());
                output.accept(ItemRegistry.CUT_BLUE_SANDSTONE.get());
                output.accept(ItemRegistry.CHISELED_BLUE_SANDSTONE.get());
                output.accept(ItemRegistry.BLUE_SANDSTONE_SLAB.get());
                output.accept(ItemRegistry.CUT_BLUE_SANDSTONE_SLAB.get());
                output.accept(ItemRegistry.BLUE_SANDSTONE_STAIRS.get());
                output.accept(ItemRegistry.BLUE_SANDSTONE_WALL.get());
                output.accept(ItemRegistry.SMOOTH_BLUE_SANDSTONE.get());
                output.accept(ItemRegistry.SMOOTH_BLUE_SANDSTONE_SLAB.get());
                output.accept(ItemRegistry.SMOOTH_BLUE_SANDSTONE_STAIRS.get());

                output.accept(ItemRegistry.HARANO_LOG.get());
                output.accept(ItemRegistry.HARANO_WOOD.get());
                output.accept(ItemRegistry.STRIPPED_HARANO_LOG.get());
                output.accept(ItemRegistry.STRIPPED_HARANO_WOOD.get());
                output.accept(ItemRegistry.HARANO_PLANKS.get());
                output.accept(ItemRegistry.HARANO_STAIRS.get());
                output.accept(ItemRegistry.HARANO_SLAB.get());
                output.accept(ItemRegistry.HARANO_FENCE.get());
                output.accept(ItemRegistry.HARANO_FENCE_GATE.get());
                output.accept(ItemRegistry.HARANO_PRESSURE_PLATE.get());
                output.accept(ItemRegistry.HARANO_DOOR.get());
                output.accept(ItemRegistry.HARANO_TRAPDOOR.get());
                output.accept(ItemRegistry.HARANO_BUTTON.get());
                output.accept(ItemRegistry.HARANO_LEAVES.get());
                output.accept(ItemRegistry.HARANO_SAPLING.get());

                output.accept(ItemRegistry.FUKAMIZU_PLUM_LOG.get());
                output.accept(ItemRegistry.FUKAMIZU_PLUM_WOOD.get());
                output.accept(ItemRegistry.STRIPPED_FUKAMIZU_PLUM_LOG.get());
                output.accept(ItemRegistry.STRIPPED_FUKAMIZU_PLUM_WOOD.get());
                output.accept(ItemRegistry.FUKAMIZU_PLUM_PLANKS.get());
                output.accept(ItemRegistry.FUKAMIZU_PLUM_STAIRS.get());
                output.accept(ItemRegistry.FUKAMIZU_PLUM_SLAB.get());
                output.accept(ItemRegistry.FUKAMIZU_PLUM_FENCE.get());
                output.accept(ItemRegistry.FUKAMIZU_PLUM_FENCE_GATE.get());
                output.accept(ItemRegistry.FUKAMIZU_PLUM_PRESSURE_PLATE.get());
                output.accept(ItemRegistry.FUKAMIZU_PLUM_DOOR.get());
                output.accept(ItemRegistry.FUKAMIZU_PLUM_TRAPDOOR.get());
                output.accept(ItemRegistry.FUKAMIZU_PLUM_BUTTON.get());
                output.accept(ItemRegistry.FUKAMIZU_PLUM_LEAVES.get());
                output.accept(ItemRegistry.FUKAMIZU_PLUM_SAPLING.get());

                output.accept(ItemRegistry.HARDEN_CRYSTAL_BLOCK.get());
                output.accept(ItemRegistry.PURIFIED_CRYSTAL_BLOCK.get());
                output.accept(ItemRegistry.CHARGED_CRYSTAL_BLOCK.get());
                output.accept(ItemRegistry.ANTI_INGOT_BLOCK.get());
                output.accept(ItemRegistry.GACHI_INGOT_BLOCK.get());

                output.accept(ItemRegistry.VERDANT_SPIRIT_RICH_SOIL.get());
                output.accept(ItemRegistry.VERDANT_SPIRIT_FARMLAND.get());

                output.accept(ItemRegistry.PHANTASMAL_VOYAGER.get());
                output.accept(ItemRegistry.CRYSTAL_POPPER.get());
                output.accept(ItemRegistry.CRYSTAL_PURIFIER.get());
                output.accept(ItemRegistry.CRYSTAL_CUTTER.get());

                output.accept(ItemRegistry.FUKAMIZU_BREAD_BLOCK.get());
                output.accept(ItemRegistry.FUKAMIZU_BREAD_BRICKS.get());
                output.accept(ItemRegistry.HQSS_BREAD_BRICKS.get());

                output.accept(ItemRegistry.FUKAMIZU_MACHINE_CASING.get());
                output.accept(ItemRegistry.FUKAMIZU_COMPRESSOR.get());
                output.accept(ItemRegistry.FUKAMIZU_PYLON.get());
                output.accept(ItemRegistry.LIGHT_BREAD_ENERGY_BLOCK.get());
                output.accept(UCEnergyBlockItem.makeFullEnergyStack(ItemRegistry.LIGHT_BREAD_ENERGY_BLOCK.get(),
                        BlockEntityRegistry.LIGHT_BREAD_ENERGY_BLOCK_ENTITY.get(), LightBreadEnergyBlockEntity.MAX_ENERGY));
                output.accept(ItemRegistry.FUKAMIZU_CRUSHER.get());
                output.accept(ItemRegistry.FUKAMIZU_BREAD_FURNACE.get());
                output.accept(ItemRegistry.FUKAMIZU_REACTION_CHAMBER.get());

                output.accept(ItemRegistry.REINFORCED_FUKAMIZU_MACHINE_CASING.get());
                output.accept(ItemRegistry.UMISU_PYLON.get());
                output.accept(ItemRegistry.MOLTEN_BREAD_ENERGY_BLOCK.get());
                output.accept(UCEnergyBlockItem.makeFullEnergyStack(ItemRegistry.MOLTEN_BREAD_ENERGY_BLOCK.get(),
                        BlockEntityRegistry.MOLTEN_BREAD_ENERGY_BLOCK_ENTITY.get(), MoltenBreadEnergyBlockEntity.MAX_ENERGY));
                output.accept(ItemRegistry.FUKAMIZU_TURBINE_ENGINE.get());
                output.accept(ItemRegistry.FUKAMIZU_PUNCH.get());
                output.accept(ItemRegistry.FUKAMIZU_FERMENTER.get());
                output.accept(ItemRegistry.FUKAMIZU_EXTRACTION_MACHINE.get());
                output.accept(ItemRegistry.FUKAMIZU_BOOSTER.get());
                output.accept(ItemRegistry.FUKAMIZU_FISHERY.get());
            })
            .build();

    public static CreativeModeTab TAPE_TAB = CreativeModeTab.builder()
            .title(Component.translatable("itemGroup.dreamaticvoyage_tapes_tab"))
            .withTabsBefore(TabRegistry.MOD_BLOCK_TAB.getKey())
            .icon(() -> new ItemStack(ItemRegistry.AUDIO_TAPE_HAINE_1.get()))
            .displayItems((param, output) -> ItemRegistry.AUDIO_ITEMS.getEntries().forEach((registryObject) -> {
                if (!HIDDEN.contains(registryObject)) {
                    output.accept(registryObject.get());
                }
            }))
            .build();
}
